package com.isxcode.link.plugin.controller;

import com.isxcode.link.common.constant.UrlConstants;
import com.isxcode.link.common.pojo.dto.LinkData;
import com.isxcode.link.common.pojo.LinkRequest;
import com.isxcode.link.plugin.response.SuccessResponse;
import com.isxcode.link.plugin.service.LinkBizService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/*
 * 插件controller入口
 *
 * @ispong
 */
@RestController
@RequestMapping
@RequiredArgsConstructor
public class LinkController {

    private final LinkBizService linkBizService;

    @SuccessResponse
    @PostMapping(UrlConstants.EXECUTE_URL)
    public LinkData execute(@RequestBody LinkRequest linkRequest) {

        return linkBizService.execute(linkRequest);
    }

    @SuccessResponse
    @PostMapping(UrlConstants.GET_JOB_LOG_URL)
    public LinkData getJobLog(@RequestBody LinkRequest linkRequest) {

        return linkBizService.getJobLog(linkRequest);
    }

    @SuccessResponse
    @GetMapping(UrlConstants.HEART_CHECK_URL)
    public LinkData heartCheck() {

        return LinkData.builder().log("正常").build();
    }
}
